<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %>

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<html:html>
<head>
	<link rel="stylesheet" type="text/css" href="<%= request.getContextPath() %>/common/css/stkissue/stkissue.css" />	
	<link rel="stylesheet" type="text/css" href="<%= request.getContextPath() %>/css/sampleForm.css" />
	<link rel="stylesheet" type="text/css" href="<%= request.getContextPath() %>/css/me.css" />
	<link rel="stylesheet" type="text/css" href="<%= request.getContextPath() %>/common/css/help/help.css" />	
	<title>บันทึกใบขอเบิกใช้สินค้า, วัตถุดิบ (BCStkIssue, BCStkIssueSub)</title>
	<script type='text/javascript' src='/ittl/dwr/interface/BCProjectService.js'></script>
  	<script type='text/javascript' src='/ittl/dwr/interface/ItemLocationService.js'></script>
  	<script type='text/javascript' src='/ittl/dwr/engine.js'></script>
  	<script type='text/javascript' src='/ittl/dwr/util.js'></script>

	<script type='text/javascript' src='<%= request.getContextPath() %>/css/autocomplete/lib/jquery.js' ></script>
	<script type='text/javascript' src='<%= request.getContextPath() %>/css/autocomplete/lib/jquery.bgiframe.min.js1' ></script>
	<script type='text/javascript' src='<%= request.getContextPath() %>/css/autocomplete/lib/jquery.ajaxQueue.js1' ></script>
	<script type='text/javascript' src='<%= request.getContextPath() %>/css/autocomplete/lib/thickbox-compressed.js1' ></script>
	<script type='text/javascript' src='<%= request.getContextPath() %>/css/autocomplete/lib/jquery.autocomplete.js' ></script>
	
	<script type='text/javascript' src='<%= request.getContextPath() %>/css/autocomplete/data/localdata.js' ></script>
	<script type='text/javascript' src='<%= request.getContextPath() %>/css/autocomplete/data/localdata2.js' ></script>
	<script type='text/javascript' src='<%= request.getContextPath() %>/css/autocomplete/data/localdata2Name.js' ></script>
	<script type='text/javascript' src='<%= request.getContextPath() %>/css/autocomplete/data/localdata31.js' ></script>
	<script type='text/javascript' src='<%= request.getContextPath() %>/css/autocomplete/data/localdataDepartment.js' ></script>
	<script type='text/javascript' src='<%= request.getContextPath() %>/css/autocomplete/data/localdataDepartmentName.js' ></script>
	
	
	<link rel="stylesheet" type="text/css" href="<%= request.getContextPath() %>/css/autocomplete/css/mainOLD.css" />
	<link rel="stylesheet" type="text/css" href="<%= request.getContextPath() %>/css/autocomplete/css/jquery.autocomplete.css" />
	<link rel="stylesheet" type="text/css" href="<%= request.getContextPath() %>/css/autocomplete/css/thickbox.css" />
 
 	<script type="text/javascript" src="<%= request.getContextPath() %>/stockRequest/jquery.validate.js" ></script>
 	<script type="text/javascript" src="<%= request.getContextPath() %>/stockRequest/jquery-1.4.2.min1.js" ></script>

<!-- start 
 
	<link type="text/css" href="<%= request.getContextPath() %>/jquery-ui-1.8/development-bundle/themes/base/jquery.ui.all.css" rel="stylesheet" />
	<link type="text/css" href="<%= request.getContextPath() %>/jquery-ui-1.8/development-bundle/demos/demos.css" rel="stylesheet" />
	  	
	<script type="text/javascript" src="<%= request.getContextPath() %>/jquery-ui-1.8/development-bundle/jquery-1.4.2.js"></script>
	<script type="text/javascript" src="<%= request.getContextPath() %>/jquery-ui-1.8/development-bundle/external/jquery.bgiframe-2.1.1.js"></script>			
	<script type="text/javascript" src="<%= request.getContextPath() %>/jquery-ui-1.8/development-bundle/ui/jquery.ui.core.js"></script>
	<script type="text/javascript" src="<%= request.getContextPath() %>/jquery-ui-1.8/development-bundle/ui/jquery.ui.widget.js"></script>
	<script type="text/javascript" src="<%= request.getContextPath() %>/jquery-ui-1.8/development-bundle/ui/jquery.ui.mouse.js"></script>
	<script type="text/javascript" src="<%= request.getContextPath() %>/jquery-ui-1.8/development-bundle/ui/jquery.ui.button.js"></script>
	<script type="text/javascript" src="<%= request.getContextPath() %>/jquery-ui-1.8/development-bundle/ui/jquery.ui.draggable.js"></script>
	<script type="text/javascript" src="<%= request.getContextPath() %>/jquery-ui-1.8/development-bundle/ui/jquery.ui.position.js"></script>
	<script type="text/javascript" src="<%= request.getContextPath() %>/jquery-ui-1.8/development-bundle/ui/jquery.ui.resizable.js"></script>
	<script type="text/javascript" src="<%= request.getContextPath() %>/jquery-ui-1.8/development-bundle/ui/jquery.ui.dialog.js"></script>
	<script type="text/javascript" src="<%= request.getContextPath() %>/jquery-ui-1.8/development-bundle/ui/jquery.effects.core.js"></script>
	<script type="text/javascript" src="<%= request.getContextPath() %>/jquery-ui-1.8/development-bundle/ui/jquery.ui.datepicker.js"></script>
	<script type="text/javascript" src="<%= request.getContextPath() %>/jquery-ui-1.8/development-bundle/ui/jquery.ui.autocomplete.js"></script>
			
-->
<!-- end -->

<!-- start add/remove  
	<script type="text/javascript" src='<%= request.getContextPath() %>/common/js/addremove/jquery-latest.pack.js'></script>	
-->	
	<script type="text/javascript" src='<%= request.getContextPath() %>/common/js/addremove/jquery.highlightFade.js'></script>
		
	<script type="text/javascript">
				
	var id = 1;	
	var idArray = new Array();
	idArray[0] = 1;
	idArray[1] = 1;
	idArray[2] = 1;
	idArray[3] = 1;
//	idArray[4] = 1;
	var max = false;
	
	function addFormField() {
		max = true;
		for (i=0; i<idArray.length; i++) {
			if(idArray[i]==0) {
				max = false;
				idArray[i] = 1;
				id = i+1; 
				i = idArray.length;

				//alert(id);
				
				var newInput = "<tr id='r"+id+"'>"+
									"<td><a href='#' onClick='removeFormField(\"#r" + id + "\","+id+"); return false;'>"+
										"<img src=\"<%=request.getContextPath() %>/common/images/remove.png\" width=\"24\" height=\"24\" alt=\"Remove\" /></a></td>"+
									"<td><input	type='text' name='itemCode"+id+"' value='' size='12' "+ 
											     " onblur=\"getData(document.getElementById('suggestCode"+id+id+"').value,"+id+")\" id=\"suggestCode"+id+id+"\"> "+
										"</td><td></td> "+
										"<td><input type='text' name='itemName"+id+"' value='' maxlength='200' size='40' id='itemName"+id+"' >"+														
									"</td><td></td>"+
									
									"<td align='center'><input type='text' name='unitName"+id+"' value='' size='5' id='unitName"+id+"' >"+																																
									"	 <input	type='hidden' name='unitCode"+id+"' value='001' id='unitCode"+id+"'>"+
									"	 <input	type='hidden' name='price"+id+"' value='0' id='price"+id+"'>"+
									"	 <input	type='hidden' name='amount"+id+"' value='0' id='amount"+id+"'>"+									
									"</td><td></td>"+

									
									"<td><input	type='text'	name='qty"+id+"' value='' maxlength='15' size='5' id='qty"+id+"' ></td><td></td>"+
									"<td><input	type='text'	name='division"+id+"' value='' id='division"+id+"' ></td>"+
									"<td></td>"+
								"</tr>";


				//alert(newInput);
				$("#inputs").append(newInput); 
				$('#r' + id).highlightFade({
					speed:2000
				});			
				$("#suggestCode"+id).autocomplete(codes, {
					max:30,
					minChars: 0,
					autoFill: true,
					mustMatch: true,
					matchContains: false,
					scrollHeight: 200				
				});

				$("#suggestCode"+id+id).autocomplete(itemsName, {
					minChars: 0,
					width: 400,
					max:50,
					mustMatch: true,
					matchContains: true,
					autoFill: false,
					formatItem: function(row, i, max) {
						return row.code + ": [" + row.name + "]";
					},
					formatMatch: function(row, i, max) {
						return row.code + ": [" + row.name + "]";
					},
					formatResult: function(row) {
						return row.code;
					}
				});
								
			}
		}
						
		if(max==true) {											 	
			alert("คุณสามารถเพิ่มข้อมูลได้สูงสุด 4 รายการ");
		}				
	}

	function removeFormField(rid, id) {
		var count = 0;
		for (i=0; i<idArray.length; i++) {
			if(idArray[i]>0) {
				count++;
			}
		}		
		if(count>1) {
			$(rid).remove();
			idArray[id-1] = 0;
		}else {
			alert("กรุณาบันทึกข้อมูลอย่างน้อย 1 รายการ");
		}
		
	}
		
	</script>
<!-- end add/remove  -->

<style type="text/css">
#form1 label.error {
	font-size: 1.0em;
	color: red;
}
</style>
 	
<script language="JavaScript">
 
function compareBuga() {
	return "buga22";
}

$.validator.addMethod("buga", function(value) {
	return value == compareBuga();
}, 'Please enter "buga"!');

$(document).ready(function() {	 	
			
	$("#form1").validate({
		
			
		submitHandler: function() {
			alert("txt1="+document.getElementById("txt1").value);
			alert("submitted!22");
			//$('#dialog-confirm').dialog('open');
			form.submit();
		},
				
		rules: {
			txt1: "required",
			docDate: "required",
			poDocDate: "required",
			ittl_purchaseCode: "required",			
			iTTL_deptPay: "required",
			projectCode: "required",
			itemCode1: "required",
			itemCode2: "required",
			itemCode3: "required",
			itemCode4: "required",
			itemCode5: "required",
			itemName1: "required",
			itemName2: "required",
			itemName3: "required",
			itemName4: "required",
			itemName5: "required",	
			shelfCode1: "required",
			shelfCode2: "required",
			shelfCode3: "required",
			shelfCode4: "required",
			shelfCode5: "required",		
			qty1: {
				required: 	true,
				number:		true
			},
			qty2: {
				required: 	true,
				number:		true
			},
			qty3: {
				required: 	true,
				number:		true
			},
			qty4: {
				required: 	true,
				number:		true
			},
			qty5: {
				required: 	true,
				number:		true
			}						
		},
		messages: {
			txt1: "*",
			docDate: "*",
			poDocDate: "*",
			ittl_purchaseCode: "*",
			iTTL_deptPay: "*",
			projectCode: "*",
			itemCode1: "*",
			itemCode2: "*",				
			itemCode3: "*",
			itemCode4: "*",
			itemCode5: "*",
			itemName1: "*",
			itemName2: "*",
			itemName3: "*",
			itemName4: "*",
			itemName5: "*",
			shelfCode1: "*",
			shelfCode2: "*",
			shelfCode3: "*",
			shelfCode4: "*",
			shelfCode5: "*",						
			qty1: "*Number",
			qty2: "*Number",
			qty3: "*Number",
			qty4: "*Number",
			qty5: "*Number"	
		},

		// the errorPlacement has to take the table layout into account
		errorPlacement: function(error, element) {
			//alert("errorPlacement");			
			if ( element.is(":radio") ) {
				alert("radio");
				error.appendTo( element.parent().next().next() );
			}else if ( element.is(":checkbox") ) {
				alert("checkbox");
				error.appendTo ( element.next() );
			}else {
				/*alert(element("#itemCode1"));
				if(element.is("#itemCode1")) {
					error.appendTo( "#qty1-error" );
				}else {
					error.appendTo( element.parent().next() );	
				}*/
				//error.insertAfter('#qty1-error');
				error.appendTo( element.parent().next() );
			}
		}		
	});
	

	$("#suggest1").focus().autocomplete(cities);
	
	$("#suggestProject").autocomplete(projects, {		
		max:30,
		minChars: 0,
		autoFill: true,
		mustMatch: true,
		matchContains: false,
		scrollHeight: 200
	});

	
	$("#departCode").autocomplete(departments, {		
		max:30,
		minChars: 0,
		autoFill: true,
		mustMatch: true,
		matchContains: false,
		scrollHeight: 200
	});
			
	$("#suggestDeptPay").autocomplete(departments, {		
		max:30,
		minChars: 0,
		autoFill: true,
		mustMatch: true,
		matchContains: false,
		scrollHeight: 200
	});
			
	$("#suggestCode1").autocomplete(codes, {
		max:30,
		minChars: 0,
		autoFill: true,
		mustMatch: true,
		matchContains: false,
		scrollHeight: 200				
	});
	
	$("#suggestCode2").autocomplete(codes, {
		max:30,
		minChars: 0,
		autoFill: true,
		mustMatch: true,
		matchContains: false,
		scrollHeight: 200
	});
	
	$("#suggestCode3").autocomplete(codes, {
		max:30,
		minChars: 0,
		autoFill: true,
		mustMatch: true,
		matchContains: false,
		scrollHeight: 200
	});
	
	$("#suggestCode4").autocomplete(codes, {
		max:30,
		minChars: 0,
		autoFill: true,
		mustMatch: true,
		matchContains: false,
		scrollHeight: 200
	});
	$("#suggestCode5").autocomplete(codes, {
		max:30,
		minChars: 0,
		autoFill: true,
		mustMatch: true,
		matchContains: false,
		scrollHeight: 200
	});
	
	$("#suggest11").autocomplete(cities, {
		matchContains: true,
		minChars: 0
	});

    $("#itemName5").autocomplete(cities, { scroll: true } );

	$("#suggest4").autocomplete(emails, {
		minChars: 0,
		
		matchContains: true,
		autoFill: false,
		formatItem: function(row, i, max) {
			return i + "/" + max + ": \"" + row.name + "\" [" + row.to + "]";
		},
		formatMatch: function(row, i, max) {
			return row.name + " " + row.to;
		},
		formatResult: function(row) {
			return row.to;
		}
	});

	$("#division1OLD").autocomplete(departmentsName, {
		minChars: 0,
		mustMatch: true,
		matchContains: true,
		autoFill: false,
		formatItem: function(row, i, max) {
			return row.code + ": [" + row.name + "]";
		},
		formatMatch: function(row, i, max) {
			return row.code + ": [" + row.name + "]";
		},
		formatResult: function(row) {
			return row.name;
		}
	});	

	$("#suggestCode11").autocomplete(itemsName, {
		minChars: 0,
		width: 400,
		max:50,
		mustMatch: true,
		matchContains: true,
		autoFill: false,
		formatItem: function(row, i, max) {
			return row.code + ": [" + row.name + "]";
		},
		formatMatch: function(row, i, max) {
			return row.code + ": [" + row.name + "]";
		},
		formatResult: function(row) {
			return row.code;
		}
	});

	$("#suggestCode22").autocomplete(itemsName, {
		minChars: 0,
		width: 400,
		max:50,
		mustMatch: true,
		matchContains: true,
		autoFill: false,
		formatItem: function(row, i, max) {
			return row.code + ": [" + row.name + "]";
		},
		formatMatch: function(row, i, max) {
			return row.code + ": [" + row.name + "]";
		},
		formatResult: function(row) {
			return row.code;
		}
	});			

	$("#suggestCode33").autocomplete(itemsName, {
		minChars: 0,
		width: 400,
		max:50,
		mustMatch: true,
		matchContains: true,
		autoFill: false,
		formatItem: function(row, i, max) {
			return row.code + ": [" + row.name + "]";
		},
		formatMatch: function(row, i, max) {
			return row.code + ": [" + row.name + "]";
		},
		formatResult: function(row) {
			return row.code;
		}
	});	

	$("#suggestCode44").autocomplete(itemsName, {
		minChars: 0,
		width: 400,
		max:50,
		mustMatch: true,
		matchContains: true,
		autoFill: false,
		formatItem: function(row, i, max) {
			return row.code + ": [" + row.name + "]";
		},
		formatMatch: function(row, i, max) {
			return row.code + ": [" + row.name + "]";
		},
		formatResult: function(row) {
			return row.code;
		}
	});	

	$("#suggestCode55").autocomplete(itemsName, {
		minChars: 0,
		width: 400,
		max:50,
		mustMatch: true,
		matchContains: true,
		autoFill: false,
		formatItem: function(row, i, max) {
			return row.code + ": [" + row.name + "]";
		},
		formatMatch: function(row, i, max) {
			return row.code + ": [" + row.name + "]";
		},
		formatResult: function(row) {
			return row.code;
		}
	});	
	
});

</script>  

<!--  ส่วนที่ 2 -->
<script language="JavaScript">
var inputNo;
var itemName = "";
var code;
var itemName;
var whCode;
var shelfCode;
var shelfName;

function getData(var1,x) {	
	inputNo = x;
	ItemLocationService.getData( var1, loadinfo );	  
}

<!--  ส่วนที่ 3 -->
function loadinfo(data)
{
	code 	  = data.code;
	itemName  = data.name1;
	whCode 	  = data.whCode;
	shelfCode = data.shelfCode;
	shelfName = data.shelfName;
	unitCode = data.unitCode;
	unitName = data.unitName;

	ittl_row = data.ittl_row;
	ittl_shelf = data.ittl_shelf;
	
	switch(inputNo) {
	case 1:	dwr.util.setValue("itemCode1", code);
			dwr.util.setValue("itemName1", itemName);
			dwr.util.setValue("whCode1", whCode);
			dwr.util.setValue("whCode11", whCode);
			dwr.util.setValue("unitCode1", unitCode);
			dwr.util.setValue("unitName1", unitName);
			//redirectN(0, document.getElementById('shCode1'));		
			
			dwr.util.setValue("ittl_row1", ittl_row);
			dwr.util.setValue("ittl_shelf1", ittl_shelf);						
			break;
			
	case 2:	dwr.util.setValue("itemCode2", code);
			dwr.util.setValue("itemName2", itemName);
			dwr.util.setValue("whCode2", whCode);			
			dwr.util.setValue("unitCode2", unitCode);
			dwr.util.setValue("unitName2", unitName);
			//redirectN(0, document.getElementById('shCode2'));
			
			dwr.util.setValue("ittl_row2", ittl_row);
			dwr.util.setValue("ittl_shelf2", ittl_shelf);						
			break;
			
	case 3:	dwr.util.setValue("itemCode3", code);
			dwr.util.setValue("itemName3", itemName);
			dwr.util.setValue("whCode3", whCode);			
			dwr.util.setValue("unitCode3", unitCode);
			dwr.util.setValue("unitName3", unitName);
			//redirectN(0, document.getElementById('shCode3'));
			
			dwr.util.setValue("ittl_row3", ittl_row);
			dwr.util.setValue("ittl_shelf3", ittl_shelf);						
			break;
	case 4:	dwr.util.setValue("itemCode4", code);
			dwr.util.setValue("itemName4", itemName);
			dwr.util.setValue("whCode4", whCode);			
			dwr.util.setValue("unitCode4", unitCode);
			dwr.util.setValue("unitName4", unitName);
			//redirectN(0, document.getElementById('shCode4'));
			dwr.util.setValue("ittl_row4", ittl_row);
			dwr.util.setValue("ittl_shelf4", ittl_shelf);						
			break;
	case 5:	dwr.util.setValue("itemCode5", code);
			dwr.util.setValue("itemName5", itemName);
			dwr.util.setValue("whCode5", whCode);			
			dwr.util.setValue("unitCode5", unitCode);
			dwr.util.setValue("unitName5", unitName);
			//redirectN(0, document.getElementById('shCode5'));//ใช้ document.form1.shelfCode5 จะทำงานได้บน IE แต่ไม่ไได้บน FF
			dwr.util.setValue("ittl_row5", ittl_row);
			dwr.util.setValue("ittl_shelf5", ittl_shelf);						
			break;
	}		
}

function redirectN(x, tempN){
	
	var groupsN=5;//document.form1.shelfCode1.options.length
	var groupN=new Array(groupsN);
	for (i=0; i<groupsN; i++)
		groupN[i]=new Array();

	//var tempN=document.form1.shelfCode1;	
	//alert("tempN.options.length-1 = "+(tempN.options.length-1));
	for (m=tempN.options.length-1;m>=0;m--) {
		//alert(tempN.options[m]);
		tempN.options[m]=null;
	}
	
	if(shelfName != null) {
		for (i=0; i<shelfName.length; i++) {
			groupN[0][i]=new Option(shelfName[i], shelfCode[i]);
		}
					
		for (i=0;i<groupN[x].length;i++){
			text = groupN[x][i].value+":"+groupN[x][i].text;
			tempN.options[i]=new Option(text,groupN[x][i].value);
		}
		tempN.options[0].selected=true;
	}
}
</script>
<!--  ส่วนที่ 2 -->
<script language="JavaScript">

function getProject() {
	//alert("bcproject"+form1.projectCode.value); ใช้ใน ff ไม่ผ่าน			
	BCProjectService.getProject( document.getElementById("suggestProject").value, loadinfoProject );			  
}

<!--  ส่วนที่ 3 -->
function loadinfoProject(project){		
	//dwr.util.setValue("projectCode", project.name);
	dwr.util.setValue("projectName", project.name);			     
}
</script>	

<script type="text/javascript">
function alertValue() {
	alert(document.getElementById('htmlElementTest').value)
}
</script>

	<link type="text/css" href="<%= request.getContextPath() %>/css/datepicker/css/ui.all.css" rel="stylesheet" /> 
	
	<script type="text/javascript" src="<%= request.getContextPath() %>/css/datepicker/lib/jquery-ui-1.5.3.min.js"></script>
	

	<script type="text/javascript">
		$(document).ready(function(){
    			$("#docDate").datepicker({ altField: 'input#docDate', altFormat: 'yy-mm-dd' });
    			$("#poDocDate").datepicker({ altField: 'input#poDocDate', altFormat: 'yy-mm-dd' });
    			$("#stkIssueDocDate").datepicker({ altField: 'input#stkIssueDocDate', altFormat: 'yy-mm-dd' });
    			
  		});
	</script>


</head>

<body>

<div id="wrapper">
	<!-- 
		<div id="header"><img src="images/kiuchilogo.png" width="305" height="80" /></div>
	 -->	 
	<div id="menu"><ul id="nav"></ul></div>
	  
	<div id="content">
		<div id="menuNav">			
			<a href="<%=request.getContextPath() %>/Login.do?mode=check" >Home</a> 
			>> คลังพัสดุ - Store กลาง  
			>> จัดซื้อ
			>> <a href="<%=request.getContextPath() %>/purchaseOrder/purchaseOrder.do?mode=findAll&d-49653-p=${inPage }&docNo=${reqForm.docNo}" >สร้าง PO จากใบ พ.1 (ขอซื้อ)</a>
			>> สร้างใบ PO  
		</div>		<br />

					
	<div style="background: #ffffff;">	
		<p align="center" id="titleIssueType">บันทึกใบเสนอราคา (Purchase Order)</p>				
	
	<html:form action="/purchaseOrder.do?mode=add&changePO=yes" styleId="form1"  >
		                
	<div id="stkIssue">
	<fieldset>
		<legend><b>ข้อมูลใบเสนอราคา </b></legend>
		   <center> 
		   <table border="0" width=65%>
			<tr>
				<td align="right">เลขที่เอกสาร :</td>
				<td ><input type="text" name="poDocNo" value="${purchaseOrderDocNo}" readonly="readonly" id="poDocNo" ></td>
				<td ></td></tr>
			<tr>
				<td align="right">Purchase Code :</td>
				<td ><input type="text" name="ittl_purchaseCode" value="${ttl_purchaseOrderDocNo }" id="ittl_purchaseCode" ></td>
				<td ></td></tr>				
			<tr>
				<td align="right">วันที่ออกใบPO :</td>
				<td ><input type="text" name="poDocDate" id="poDocDate" maxlength="100" value="" ></td>
				<td ></td></tr>
			<tr>
 				<td align="right">ผู้บันทึกข้อมูล :</td>
 				<td><input type="text" name="poCreatorCode" value="${userName}" readonly="readonly"></td>
 				<td ></td></tr>
 			<tr>
 				<td align="right">หมายเหตุ :</td>
 				<td colspan="2"><input type="text" name="poMyDescription" value='' maxlength="200" size="50" >
 				<input	type="hidden" name="apCode" value="000" id="apCode">
 				<input	type="hidden" name="currencyCode" value="BAHT" id="currencyCode">
 				
 				</td> 				
 			</tr> 			 			 			 				 						
		</table>
		</center>
     </fieldset></div>        
	<div id="userPw01">
	<fieldset>
		<legend><b>ข้อมูลใบขอซื้อ</b></legend>
		   <center> 
		   <table border="0" width='65%'>
			<tr>
				<td align="right"> เลขที่เอกสาร :</td>
				<td ><input type="text" name="docNo" value="${reqForm.docNo }" readonly="readonly" id="docNo" ></td>
				<td ></td></tr>
			<tr>
				<td align="right"> วันที่ขอเบิก :</td>
				<td ><input type="text" name="docDate" id="docDate" maxlength="100" value="${reqForm.docDate }" ></td>
				<td ></td></tr>			
			<tr>
				<td align="right">ฝ่ายผู้เบิก :</td>
				<td ><input type="text" name="iTTL_deptRequest" value="${reqForm.iTTL_deptRequest }" id="suggestDeptPay" ></td>
				<td ></td></tr>			 		
			<tr>
				<td align="right">ฝ่ายชำระเงิน :</td>
				<td><input type="text" name="departCode" maxlength="3" value="${reqForm.departCode }" id="departCode" ></td>
				<td ></td></tr>
 			<tr>
 				<td align="right">หน่วยงบ :</td>
 				<td><input type="text" name="projectCode" value="${reqForm.projectCode }" id="suggestProject" ><!-- onblur="getProject()"  --></td>
 				<td ></td></tr>			
 			<tr>
 				<td align="right">ผู้บันทึกข้อมูล :</td>
 				<td><input type="text" name="creatorCode" value="${reqForm.creatorCode }" readonly="readonly"></td>
 				<td ></td></tr>
 			<tr>
 				<td align="right">หมายเหตุ :</td>
 				<td colspan="2"><input type="text" name="myDescription" value='${reqForm.myDescription }' maxlength="200" size="50" ></td> 				
 			</tr>
 			 			 			 				 							
		</table>
		</center>
     </fieldset></div>
    <div id="items"> 
     <fieldset>
     	<legend><b>รายการสินค้า, วัตถุดิบ, อุปกรณ์</b></legend>     	
<!--      	     	
     	<p><a href="#" onClick="addFormField(); return false;">
     			<img src="<%=request.getContextPath() %>/common/images/add.png" width="24" height="24" alt="Add" />
     		</a>     			   
     	</p>
 -->     	
     		<input type="hidden" id="id" value="0">
     	<center>	     		          	
		<table border="0" >
			<thead>
				<tr id="rHead">
					<th width="24"></th>
				  <th width="100" align="center">รหัสสินค้า</th>
				  <th width="10"></th>
				  <th width="270" align="center">ชื่อรายการ</th>
				  <th width="10"></th>				

				  <th width="70"  align="center">หน่วยนับ</th>
				  <th width="10"></th>
				  <th width="60"  align="center">จำนวน</th> 
				  <th width="60"></th>
				  <th width="60"  align="center">หน่วยที่เบิก</th>
				  <th width="60"></th>				
				</tr>						
			</thead>
			
			<tbody id="inputs">
<c:if test="${!empty reqForm.itemCode1}">
				<tr id="r1">
					<td><a href='#' onClick='removeFormField("#r1",1); return false;'>
						<img src="<%=request.getContextPath() %>/common/images/remove.png" width="24" height="24" alt="Remove" /></a>
						<input type="text" name="rowOrder1" value="${reqForm.rowOrder1 }">
					</td>								
				  	<td><input 	type="text" name="itemCode1" value="${reqForm.itemCode1 }" size="12" 
				  				onblur="getData(document.getElementById('suggestCode11').value,1)" id="suggestCode11" >			  		
				  	</td><td></td>
					<td><input 	type="text" name="itemName1" value='${reqForm.itemName1 }' maxlength="200" size="40" id="itemName1">					
						
					</td><td></td>					
					
					
					<td align="center"><input	type="text"	name="unitName1" value="${reqForm.ittl_unitName1}" size="5" id="unitName1" >					
						<input	type="hidden" name="unitCode1" value="${reqForm.unitCode1}" id="unitCode1">
						<input	type="hidden" name="price1" value="0" id="price1">
						<input	type="hidden" name="amount1" value="0" id="amount1">
					</td><td></td>
					<td><input	type="text"	name="qty1" value="${reqForm.qty1}" maxlength="15" size="5" id="qty1" ></td>
					<td></td>
					<td><input	type="text"	name="division1" value='${reqForm.division1}' id="division1" ></td>
					<td></td>					
				</tr>
</c:if>
<c:if test="${!empty reqForm.itemCode2}">  			
				<tr id="r2">
					<td><a href='#' onClick='removeFormField("#r2",2); return false;'>
						<img src="<%=request.getContextPath() %>/common/images/remove.png" width="24" height="24" alt="Remove" /></a>
						<input type="text" name="rowOrder2" value="${reqForm.rowOrder2 }">
					</td>								
				  	<td><input 	type="text" name="itemCode2" value="${reqForm.itemCode2 }" size="12" 
				  				onblur="getData(document.getElementById('suggestCode22').value,2)"
				  				onchange="getData(document.getElementById('suggestCode22').value,2)" 
				  				
				  				id="suggestCode22" >			  		
				  	</td><td></td>
					<td><input 	type="text" name="itemName2" value='${reqForm.itemName2 }' maxlength="200" size="40" id="itemName2">					
						
					</td><td></td>					


					
					<td align="center"><input	type="text"	name="unitName2" value="${reqForm.ittl_unitName2}" size="5" id="unitName2" >					
						<input	type="hidden" name="unitCode2" value="${reqForm.unitCode2}" id="unitCode2">
						<input	type="hidden" name="price2" value="0" id="price2">
						<input	type="hidden" name="amount2" value="0" id="amount2">
					</td><td></td>
					<td><input	type="text"	name="qty2" value="${reqForm.qty2}" maxlength="15" size="5" id="qty2" ></td>
					<td></td>
					<td><input	type="text"	name="division2" value='${reqForm.division2}' id="division2" ></td>
					<td></td>					
				</tr>
</c:if>
<c:if test="${!empty reqForm.itemCode3}">  
				<tr id="r3">
					<td><a href='#' onClick='removeFormField("#r3",3); return false;'>
						<img src="<%=request.getContextPath() %>/common/images/remove.png" width="24" height="24" alt="Remove" /></a>
						<input type="text" name="rowOrder3" value="${reqForm.rowOrder3 }">
					</td>								
				  	<td><input 	type="text" name="itemCode3" value="${reqForm.itemCode3 }" size="12" 
				  				onblur="getData(document.getElementById('suggestCode33').value,3)" id="suggestCode33" >			  		
				  	</td><td></td>
					<td><input 	type="text" name="itemName3" value='${reqForm.itemName3 }' maxlength="200" size="40" id="itemName3">					
						
					</td><td></td>
					

										
					<td align="center"><input	type="text"	name="unitName3" value="${reqForm.ittl_unitName3}" size="5" id="unitName3" >					
						<input	type="hidden" name="unitCode3" value="${reqForm.unitCode3}" id="unitCode3">
						<input	type="hidden" name="price3" value="0" id="price3">
						<input	type="hidden" name="amount3" value="0" id="amount3">						
					</td><td></td>
					<td><input	type="text"	name="qty3" value="${reqForm.qty3}" maxlength="15" size="5" id="qty3" ></td>
					<td></td>
					<td><input	type="text"	name="division3" value='${reqForm.division3}' id="division3" ></td>
					<td></td>					
				</tr>
</c:if>
<c:if test="${!empty reqForm.itemCode4}">  
				<tr id="r4">
					<td><a href='#' onClick='removeFormField("#r4",4); return false;'>
						<img src="<%=request.getContextPath() %>/common/images/remove.png" width="24" height="24" alt="Remove" /></a>
						<input type="text" name="rowOrder4" value="${reqForm.rowOrder4 }">
					</td>								
				  	<td><input 	type="text" name="itemCode4" value="${reqForm.itemCode4 }" size="12" 
				  				onblur="getData(document.getElementById('suggestCode44').value,4)" id="suggestCode44" >			  		
				  	</td><td></td>
					<td><input 	type="text" name="itemName4" value='${reqForm.itemName4 }' maxlength="200" size="40" id="itemName4">					
						
					</td><td></td>		
					
								
					<td align="center"><input	type="text"	name="unitName4" value="${reqForm.ittl_unitName4}" size="5" id="unitName4" >					
						<input	type="hidden" name="unitCode4" value="${reqForm.unitCode4}" id="unitCode4">
						<input	type="hidden" name="price4" value="0" id="price4">
						<input	type="hidden" name="amount4" value="0" id="amount4">						
					</td><td></td>
					<td><input	type="text"	name="qty4" value="${reqForm.qty4}" maxlength="15" size="5" id="qty4" ></td>
					<td></td>
					<td><input	type="text"	name="division4" value='${reqForm.division4}' id="division4" ></td>
					<td></td>					
				</tr>
</c:if>

												
			</tbody>
			<tfoot>

			</tfoot>						
		</table>
		</center><br></br>     	
		<font size='2'>หมายเหตุ : <font color="red">*</font> คือข้อมูลที่ต้องใส่ ${cancel }</font>
     </fieldset>
 	</div>
 	
 	<table border="0" align="center" width="100%">
 		<tr>
 			<td align="center" >

 				<html:submit  value="สร้างใบเสนอเราคา (PO)" onclick="return confirm('ยืนยัน ?');" /> 				

 			 				
 			</td>
 			<td align="center" >
 			
 				<a href="<%=request.getContextPath() %>/purchaseOrder/purchaseOrder.do?mode=create&docNo=${reqForm.docNo}&d-49653-p=${inPage }" >ยกเลิกการแก้ไข</a>
 				
 			</td> 			
 			<td align="center" >
 				<a href="<%=request.getContextPath() %>/purchaseOrder/purchaseOrder.do?d-49653-p=${inPage }&mode=findAll&docNo=${reqForm.docNo}" >กลับไปหน้า - สร้าง PO จากใบ พ.1(ขอซื้อ)</a> 				
 			</td>
 		</tr>
 	</table>    	    	    	
    </html:form><br>
    </div>

				   
<input type="hidden" value="${reqForm.itemCode2}" id="item2">
<input type="hidden" value="${reqForm.itemCode3}" id="item3">
<input type="hidden" value="${reqForm.itemCode4}" id="item4">

<script type="text/javascript">

var item2 = document.getElementById("item2").value;
var item3 = document.getElementById("item3").value;
var item4 = document.getElementById("item4").value;

	if(item2=="") {
		idArray[1] = 0;
	}
	if(item3=="") {
		idArray[2] = 0;
	}
	if(item4=="") {
		idArray[3] = 0;
	}	

function refreshForm() {
	var lAddr = document.getElementById("localAddr").value;
	var lPort = document.getElementById("localPort").value;
	var ctPath = document.getElementById("contextPath").value;	
	var inPage = document.getElementById("inPage").value;
	var docNo = document.getElementById("docNo").value;	
	window.location = "http://"+lAddr+":"+lPort+ctPath+"/reqConfirm.do?mode=approveShow&docNo="+docNo+"&d-49653-p="+inPage;		
}
function gotoStkIssue2Show() {
	
	var lAddr = document.getElementById("localAddr").value;
	var lPort = document.getElementById("localPort").value;
	var ctPath = document.getElementById("contextPath").value;	
	var inPage = document.getElementById("inPage").value;
	window.location = "http://"+lAddr+":"+lPort+ctPath+"/reqConfirm.do?d-49653-p="+inPage+"&mode=show";
}
</script>
<input type="hidden" value="<%=request.getLocalAddr() %>" id="localAddr">
<input type="hidden" value="<%=request.getLocalPort() %>" id="localPort">
<input type="hidden" value="<%=request.getContextPath() %>" id="contextPath">
<input type="hidden" value="${inPage }" id="inPage">


  	</div>
  		  
</div>


 
</body>
</html:html>